package 代码随想录.动态规划.a;

public class a746使用最小花费爬楼梯 {
    static class Solution {
        public int minCostClimbingStairs(int[] cost) {
            int n = cost.length;
            int[] dp = new int[n + 1];
            for (int i = 2; i <= n; i++) {
                int cost1 = dp[i - 2] + cost[i - 2];
                int cost2 = dp[i - 1] + cost[i - 1];
                dp[i] = Math.min(cost1, cost2);
            }
            return dp[n];
        }
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] cost = {1, 100, 1, 1, 1, 100, 1, 1, 100, 1};
        System.out.println(solution.minCostClimbingStairs(cost));
    }
}
